"order"(..., na.last=TRUE, decreasing=FALSE)
"sort"(x, decreasing=FALSE, ...)
"duplicated"(x, incomparables=FALSE, fromLast=FALSE, ...)
"unique"(x, incomparables=FALSE, fromLast=FALSE, ...)
sort,ContactMatrix-method
, one or more ContactMatrix objects with the same dimensions.
Otherwise, ignored in all other methods.
NA
values should be ordered last.
This should not be relevant as anchor indices should be finite.
x
should be considered as a non-duplicate.
sort
and unique
, a ContactMatrix object is returned with sorted or unique rows/columns, respectively.For order
, a list of two integer vectors is returned containing row/column permutations.For duplicated
, a list of logical vectors is returned specifying which rows/columns are duplicated.
anchor1
slot, while columns are ordered for increasing values of the anchor2
slot.
This equates to ordering by the coordinates directly, as the GRanges in the regions
slot is always sorted.
Based on this, sort,ContactMatrix-method
will return a sorted copy of x
with permuted rows/columns in increasing order.
This can be set to decreasing order by specifying decreasing=TRUE
.order,ContactMatrix-method
returns a list of 2 integer vectors.
The first vector contains the permutation to rearrange the rows of x
in increasing order, while the second vector does the same for the columns of x
.
If multiple objects are supplied to order
, ordering will be computed using anchor indices from successive objects.
In other words, ordering will be performed using anchor indices from the first object;
any rows with the same anchor1
or columns with the same anchor2
will be split using the corresponding indices in the second object; and so on.
duplicated,ContactMatrix-method
returns a list of two logical vectors.
The first vector indicates whether rows are duplicated, based on identical values in the anchor1
slot.
The second does the same for columns based on the anchor2
slot.
For a set of duplicated rows or columns, the first occurrence of that row/column is marked as the non-duplicate if fromLast=FALSE
, and the last entry otherwise.
unique,ContactMatrix-method
returns an ContactMatrix object where all duplicate rows and columns have been removed from x
.
This is equivalent to subsetting based on the non-duplicate rows and columns defined in duplicated,ContactMatrix-method
.
Note that sorting and duplicate identification only use the anchor indices.
The values of the matrix
slot are not used in distinguishing between rows or columns with the same index.
ContactMatrix-class
example(ContactMatrix, echo=FALSE)
anchors(x)
x2 <- sort(x)
x2
anchors(x2)
# Can also order them.
o <- order(x)
o
stopifnot(all.equal(x[o$row,o$column], x2))
# Checking duplication.
duplicated(x)
duplicated(rbind(x, x))
stopifnot(all.equal(x, unique(rbind(x, x))))
Run the code above in your browser using DataLab